package system.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import system.service.PortalService;

import common.controller.BaseController;
import common.httpModel.EasyuiDataGrid;
import common.httpModel.EasyuiDataGridJson;
import common.httpModel.Json;
import common.httpModel.Portal;
/**
 * portal 控制器
 * @author jie
 *
 */
@Controller
@RequestMapping("/portalController")
public class PortalController extends BaseController{
	private PortalService protalService;

	public PortalService getProtalService() {
		return protalService;
	}
	@Autowired
	public void setProtalService(PortalService protalService) {
		this.protalService = protalService;
	}
	
	@RequestMapping(params = "show")
	@ResponseBody
	public EasyuiDataGridJson show(EasyuiDataGrid dg, Portal portal) {
		return datagrid(dg, portal);
	}
	
	@RequestMapping(params="datagrid")
	@ResponseBody
	public EasyuiDataGridJson datagrid(EasyuiDataGrid dg, Portal portal) {
		return protalService.datagrid(dg, portal);
	}
	
	/**
	 * 转到portal 管理页面
	 * @return
	 */
	@RequestMapping(params="portal")
	public String portal(){
		
		return "/admin/portal";
	}
	
	@RequestMapping(params = "edit")
	@ResponseBody
	public Json edit(Portal portal) {
		Json j = new Json();
		protalService.edit(portal);
		j.setMsg("编辑成功！");
		j.setSuccess(true);
		return j;
	}

	@RequestMapping(params = "add")
	@ResponseBody
	public Json add(Portal portal) {
		Json j = new Json();
		protalService.add(portal);
		j.setSuccess(true);
		return j;
	}
	
	@RequestMapping(params = "del")
	@ResponseBody
	public Json del(String ids) {
		Json j = new Json();
		protalService.del(ids);
		j.setSuccess(true);
		return j;
	}
}
